Imports system.Xml.Serialization
Imports system.io
Public Class LogSplitter
    Private Const XmlFilename As String = "RaidEncounters.xml"

    Public Structure EncounterEntry
        <XmlAttribute()> Dim patch As Single
        <XmlAttribute()> Dim zone As String
        <XmlAttribute()> Dim name As String
        <XmlAttribute()> Dim abbreviation As String ' short name
        <XmlAttribute()> Dim timeOut As Integer

        <XmlAttribute()> Dim people As String
        <XmlElement()> Dim Difficulty() As DifficultyEntry

        <XmlAttribute()> Dim start() As Integer
        <XmlAttribute()> Dim proceed() As Integer
        <XmlAttribute()> Dim finish() As Integer

        <XmlAttribute()> Dim isKillAll As Boolean
        <XmlAttribute()> Dim isTurnFriendly As Boolean
        <XmlAttribute()> Dim killCount() As Boolean
    End Structure

    Public Structure DifficultyEntry
        <XmlAttribute()> Dim name As String

        <XmlAttribute()> Dim actorId As Integer
        <XmlAttribute()> Dim spellId() As Integer
        <XmlAttribute()> Dim note As String
    End Structure

    Public Shared Encounters() As EncounterEntry

    Public Sub New()
        Dim XU As New XmlUtils.AccessXml

        If Encounters Is Nothing Then
            ReDim Encounters(0)
            Encounters(0) = New EncounterEntry
            Encounters(0).name = "Dummy"
            ReDim Encounters(0).Difficulty(0)
            Encounters(0).Difficulty(0) = New DifficultyEntry
            Encounters(0).Difficulty(0).name = 10

            Try
                XU.ImportFromXml(Encounters, getXmlFilename(XmlFilename))
            Catch ex As Exception
                Dim EH As New ErrorHandler
                EH.ErrorMsgBox(ex, "LogSplitter.New ImportFromXml")
            End Try
        End If
    End Sub

    Protected Overrides Sub Finalize()
        'Dim XU As New XmlUtils.AccessXml
        'Try
        '    XU.ExportByXml(Encounters, getXmlFilename(XmlFilename))
        'Catch ex As Exception
        '    Dim EH As New ErrorHandler
        '    EH.ErrorMsgBox(ex, "LogSplitter.Finalize ExportByXml")
        'End Try

        MyBase.Finalize()
    End Sub

    Private Function getXmlFilename(ByVal filename As String) As String
        Dim path As String = My.Computer.FileSystem.SpecialDirectories.AllUsersApplicationData
        Return My.Computer.FileSystem.CombinePath(path, filename)
    End Function

End Class
